/*
 * Copyright 2006-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.martinimix.context.event.syndication;

import net.martinimix.domain.syndication.SyndicationFeed;
import net.martinimix.service.syndication.SyndicationFeedPublishingService;

import org.springframework.context.ApplicationEvent;

/**
 * Provides an application event fired when a syndication feed
 * is published.
 * 
 * @author Scott Rossillo
 *
 */
public class SyndicationFeedPublishedEvent extends ApplicationEvent {

	private static final long serialVersionUID = 1L;
	
	private final SyndicationFeed feed;
	private final String url;
	
	/**
	 * Creates a new syndication feed published event for the given source,
	 * feed and url.
	 * 
	 * @param source the <code>SyndicationFeedPublishingService</code> triggering
	 * this event
	 * 
	 * @param feed the published <code>SyndicationFeed</code>
	 * 
	 * @param url the publicly accessible URL for the published <code>feed</code>
	 */
	public SyndicationFeedPublishedEvent(SyndicationFeedPublishingService source, SyndicationFeed feed, String url) {
		super(source);
		
		if(feed == null) {
			throw new IllegalArgumentException("[SyndicationFeed] cannot be null!");
		}
		
		if(url == null) {
			throw new IllegalArgumentException("[url] cannot be null!");
		}
		
		this.feed = feed;
		this.url = url;
	}

	/**
	 * Returns the feed associated with this event.
	 * 
	 * @return the <code>SyndicationFeed</code> associated with this event
	 */
	public SyndicationFeed getFeed() {
		return feed;
	}
	
	/**
	 * Returns the external URL at which published version of the feed
	 * triggering this event is available.
	 *   
	 * @return the external URL for the published feed
	 */
	public String getUrl() {
		return url;
	}

	
	

}
